<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>五指山污水处理系统</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="<%=request.getContextPath()%>/huazhi/lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="<%=request.getContextPath()%>/huazhi/css/public.css" media="all">
    <link rel="shortcut icon" href="<%=request.getContextPath()%>/huazhi/images/favicon.ico"/>
    <link rel="stylesheet" href="<%=request.getContextPath()%>/css/logincss/layout.css" media="all">
    <style>
        /* 底部固定区域 */
        .layui-layout-admin .layui-footer {
            padding: 10px 0;

        }

        .layui-layout-admin .layui-footer {
            background-color: #fff;
        }
        .laydate-day-mark{
            position: absolute;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            line-height: 30px;
            font-size: 12px;
            overflow: hidden;
            background-color: #00cfe2;
        }

    </style>
</head>

<body>
<div class="layui-fluid">
    <div id="xunCha" style="margin-top: 40%;text-align: center"></div>

    <div class="layui-row">
        <div class="layui-col-md6">
            <div class="layui-col-md3">
                <button type="button"class="layui-btn layui-btn-lg" id="back" style="  width: 200px;margin-left: 70px; margin-top: 30px;">新增维保</button>
            </div>
            <div class="layui-col-md3">
                <button type="button"class="layui-btn layui-btn-lg" id="tousu" style="width: 200px;margin-left: 70px;margin-top: 30px;">投诉反馈</button>

            </div>
        </div>
        <div class="layui-col-md6">


        </div>

    </div>


</div>
</div>
<script src="<%=request.getContextPath()%>/huazhi/lib/layui-v2.5.5/layui.all.js"></script>
<script src="<%=request.getContextPath()%>/huazhi/js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script>
    layui.use(['form', 'laydate', 'layer'], function () {
        var $ = layui.$
            , form = layui.form
            , laydate = layui.laydate
            , layer = layui.layer

        var xcDates =[]

        //自定义验证规则
        form.verify({
        });
        var option ={
            elem: '#xunCha'
            ,position: 'static'
            ,showBottom: false
            ,show: true //直接显示
            ,change: function(value, date){//监听日期被切换
                console.log(value)
                console.log(date)
                getInfo(value)
            }
            ,mark:{}
        }
        $.ajax({
            type: "get",
            url: "<%=request.getContextPath()%>/rest/base/getAllDateArray",
            async: true,
            success:function (msg){
                var obj ={}
                var dates =msg.dates;
                xcDates = msg.dates;
                for (var i =0 ;i<dates.length;i++){
                    var item = dates[i]
                    obj[item] = ""
                }
                console.log(dates)
                console.log(obj)
                option.mark =obj
                laydate.render(option)
            }
        })

        function isBaohan(data){
            for (var i =0;i<xcDates.length;i++){
                var item =xcDates[i]
                if(item == data){
                    return true
                }
            }
            return  false
        }

        function getInfo(date){
            if(isBaohan(date)){
                var obj ={
                    slectDateByDate:date
                }
                $.ajax({
                    type: "post",
                    url: "<%=request.getContextPath()%>/rest/base/getlistByDatePage",
                    data:obj,
                    async: false,
                    success:function (flag){
                        if (flag){
                            window.location.href="<%=request.getContextPath()%>/phone/xzlist.jsp"
                        }

                    }
                })
            }else {
                layer.msg("这天暂时还没有巡查记录")
            }

        }

        $(document).on('click',"#back",function(){
            window.location.href="<%=request.getContextPath()%>/phone/xzwh.jsp"
        })
        $(document).on('click',"#tousu",function(){
            window.location.href="<%=request.getContextPath()%>/phone/tousu.jsp"
        })

    });
</script>
</body>
</html>